<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        /**
         * 供应商产品日期价格变化后保存上一次的价格
         */
        Schema::create('scenic_spot_goods_price_logs', function (Blueprint $table) {
            $table->id();
            $table->string('scenic_id', 32)->comment('系统生成,景点id');
            $table->string('ticket_id',32)->comment('系统生成,门票id');
            $table->string('provider', 16)->comment('供应商 这个阶段默认tuniu ,当前tuniu qunar ,self');
            $table->unsignedDecimal('sale_price',10,2)->comment('销售价 初步不加价');
            $table->unsignedDecimal('provider_sale_price',10,2)->comment('供应商销售价');
            $table->date('date')->comment('日期');
            $table->timestamps();
            $table->index(['ticket_id','scenic_id','provider'],'idx_ticket_spot');
            $table->index(['ticket_id','date'],'idx_goods_date');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('scenic_spot_goods_price_logs');
    }
};
